package com.example.zhaojianxu.signin.securities.buy

import android.app.Activity
import android.graphics.Color
import android.os.Bundle
import android.support.v7.widget.RecyclerView
import android.view.View
import com.example.zhaojianxu.signin.securities.http.BuyEntity
import com.example.zhaojianxu.signin.securities.view.BuyDialogFragment
import com.example.zhaojianxu.signin.securities.view.NumberDialogFragment
import kotlinx.android.synthetic.main.securities_item_buy.view.*

/**
 * create by @zhaojianxu on 2019/2/17
 */
class BuyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

    fun setData(date: BuyEntity) {
        itemView.item_buy_buy.text = "买进"
        itemView.item_buy_buy.setTextColor(Color.RED)
        itemView.item_buy_buy.setOnClickListener {
            val fragment = BuyDialogFragment()
            val bundle = Bundle()
            bundle.putInt("bid",date.bid)
            fragment.arguments = bundle
            fragment.show((itemView.context as? Activity)?.fragmentManager,"")
        }
        itemView.item_buy_name.text = date.name
        itemView.item_buy_number.text = date.number.toString()
        itemView.item_buy_price.text = date.price
        if (date.flag) {
            itemView.item_buy_up.text = "up"
            itemView.item_buy_up.setTextColor(Color.RED)
        }else {
            itemView.item_buy_up.text = "down"
            itemView.item_buy_up.setTextColor(Color.GREEN)
        }
    }

}